package com.esri.core.internal.a.b;

import com.esri.android.map.ags.ArcGISFeatureLayer;
import com.esri.android.map.ags.ArcGISPopupInfo;
import com.esri.core.geometry.Envelope;
import com.esri.core.geometry.Geometry;
import com.esri.core.geometry.SpatialReference;
import com.esri.core.internal.value.KMLFeatureInfo;
import com.esri.core.internal.value.d;
import com.esri.core.map.CallbackListener;
import com.esri.core.map.FeatureSet;
import com.esri.core.map.Graphic;
import com.esri.core.map.popup.PopupInfo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;
import org.codehaus.jackson.map.ObjectMapper;

/* loaded from: classes.dex */
public class c {
    List<KMLFeatureInfo> a = null;
    List<com.esri.core.internal.value.b> b = null;
    List<d> c = null;
    List<com.esri.core.internal.value.c> d = null;
    String e = null;
    Map<Geometry.Type, Map<Integer, Integer>> f = new HashMap();
    SpatialReference g;
    Envelope h;

    c() {
    }

    public List<com.esri.core.internal.value.b> a() {
        return this.b;
    }

    public Map<Geometry.Type, Map<Integer, Integer>> b() {
        return this.f;
    }

    public List<KMLFeatureInfo> c() {
        return this.a;
    }

    public Envelope d() {
        return this.h;
    }

    public SpatialReference e() {
        return this.g;
    }

    public static c a(JsonParser jsonParser, CallbackListener<Object> callbackListener) throws Exception {
        if (com.esri.core.internal.util.d.c(jsonParser)) {
            c cVar = new c();
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                String currentName = jsonParser.getCurrentName();
                jsonParser.nextToken();
                if ("featureCollection".equals(currentName)) {
                    b(jsonParser, cVar.f, callbackListener);
                } else if ("featureInfos".equals(currentName)) {
                    if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
                        cVar.a = new ArrayList();
                        while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                            cVar.a.add(KMLFeatureInfo.a(jsonParser));
                        }
                    }
                } else if ("folders".equals(currentName)) {
                    if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
                        cVar.b = new ArrayList();
                        while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                            cVar.b.add(com.esri.core.internal.value.b.a(jsonParser));
                        }
                    } else {
                        jsonParser.skipChildren();
                    }
                } else if ("groundOverlays".equals(currentName)) {
                    if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
                        cVar.d = new ArrayList();
                        while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                            com.esri.core.internal.value.c a = com.esri.core.internal.value.c.a(jsonParser);
                            cVar.d.add(a);
                            callbackListener.onCallback(a);
                        }
                    } else {
                        jsonParser.skipChildren();
                    }
                } else if ("screenOverlays".equals(currentName)) {
                    jsonParser.skipChildren();
                } else if ("networkLinks".equals(currentName)) {
                    if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
                        cVar.c = new ArrayList();
                        while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                            d a2 = d.a(jsonParser);
                            cVar.c.add(a2);
                            callbackListener.onCallback(a2);
                        }
                    } else {
                        jsonParser.skipChildren();
                    }
                } else if ("lookAtExtent".equals(currentName)) {
                    if (jsonParser.getCurrentToken() == JsonToken.START_OBJECT) {
                        double d = Double.NaN;
                        double d2 = Double.NaN;
                        double d3 = Double.NaN;
                        double d4 = Double.NaN;
                        while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                            String currentName2 = jsonParser.getCurrentName();
                            jsonParser.nextToken();
                            if ("spatialReference".equals(currentName2)) {
                                cVar.g = SpatialReference.fromJson(jsonParser);
                            } else if ("xmax".equals(currentName2)) {
                                d3 = jsonParser.getDoubleValue();
                            } else if ("xmin".equals(currentName2)) {
                                d = jsonParser.getDoubleValue();
                            } else if ("ymax".equals(currentName2)) {
                                d4 = jsonParser.getDoubleValue();
                            } else if ("ymin".equals(currentName2)) {
                                d2 = jsonParser.getDoubleValue();
                            } else {
                                jsonParser.skipChildren();
                            }
                        }
                        cVar.h = new Envelope(d, d2, d3, d4);
                    } else {
                        jsonParser.skipChildren();
                    }
                } else if ("kmlVersion".equals(currentName)) {
                    cVar.e = jsonParser.getText();
                } else {
                    jsonParser.skipChildren();
                }
            }
            return cVar;
        }
        return null;
    }

    private static void a(JsonParser jsonParser, Map<Geometry.Type, Map<Integer, Integer>> map, CallbackListener<Object> callbackListener) throws Exception {
        if (jsonParser == null || jsonParser.getCurrentToken() != JsonToken.START_OBJECT) {
            return;
        }
        ArcGISFeatureLayer arcGISFeatureLayer = null;
        HashMap hashMap = null;
        String str = null;
        while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
            String currentName = jsonParser.getCurrentName();
            jsonParser.nextToken();
            if ("popupInfo".equals(currentName)) {
                ArcGISPopupInfo arcGISPopupInfo = new ArcGISPopupInfo(PopupInfo.fromJson(jsonParser));
                arcGISPopupInfo.setWebMapFeatureCollection(true);
                HashMap hashMap2 = new HashMap();
                hashMap2.put(0, arcGISPopupInfo);
                if (arcGISFeatureLayer != null) {
                    arcGISFeatureLayer.setPopupInfos(hashMap2);
                }
            } else if ("featureSet".equals(currentName)) {
                if (jsonParser.getCurrentToken() == JsonToken.START_OBJECT) {
                    Geometry.Type type = null;
                    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                        String currentName2 = jsonParser.getCurrentName();
                        jsonParser.nextToken();
                        if ("features".equals(currentName2)) {
                            if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
                                while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                                    Graphic fromJson = Graphic.fromJson(jsonParser);
                                    if (fromJson != null) {
                                        if (arcGISFeatureLayer == null) {
                                            arcGISFeatureLayer = new ArcGISFeatureLayer(str, (String) null, (FeatureSet) null, (ArcGISFeatureLayer.Options) null, true);
                                            hashMap = new HashMap();
                                            if (callbackListener != null) {
                                                callbackListener.onCallback(arcGISFeatureLayer);
                                            }
                                        }
                                        hashMap.put((Integer) fromJson.getAttributeValue("id"), Integer.valueOf(arcGISFeatureLayer.addGraphic(fromJson)));
                                    }
                                }
                            }
                        } else if ("geometryType".equals(currentName2)) {
                            type = com.esri.core.internal.util.d.b(jsonParser.getText());
                        } else {
                            jsonParser.skipChildren();
                        }
                    }
                    map.put(type, hashMap);
                }
            } else if ("layerDefinition".equals(currentName)) {
                str = new ObjectMapper().readTree(jsonParser).toString();
            } else {
                jsonParser.skipChildren();
            }
        }
    }

    private static void b(JsonParser jsonParser, Map<Geometry.Type, Map<Integer, Integer>> map, CallbackListener<Object> callbackListener) throws Exception {
        if (com.esri.core.internal.util.d.c(jsonParser)) {
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                String currentName = jsonParser.getCurrentName();
                jsonParser.nextToken();
                if ("layers".equals(currentName)) {
                    if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
                        while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                            a(jsonParser, map, callbackListener);
                        }
                    } else {
                        jsonParser.skipChildren();
                    }
                }
            }
        }
    }
}
